/**
 * PrimeArray class
 *
 * @author sergei
 *
 * @date 24 Jan 2013
 */
package prime;

/**
 * Class PrimeArray that realizes structure of array of prime numbers.
 */
class PrimeArray {

    /**
     * Pointer to array of prime numbers.
     */
    public int[] primeNumbersArray;
    
    /**
     * Number of prime numbers in array on the current moment.
     */
    public int length;
    
    /**
     * Class constructor that creates an array of inputed size.
     * @param size Number of prime numbers to be found.
     */
    public PrimeArray(int size){
        primeNumbersArray = new int[size];
        length = 0;
    }

    /**
     * Boolean method isNotDividable checks if entered value divides on any 
     * number in array.
     * @param  value Value, that must be checked.
     * @return       true if input value don't divides on any number in
     *               array, false otherwise.
     */
    public boolean isNotDividable(int value){
        for (int i = 0; i < length; i++) {
            if (value % primeNumbersArray[i] == 0) {
                return false;
            }
        }
        return true;
    }
    
    /**
     * Method print prints all prime numbers in array.
     */
    public void print() throws IllegalStateException{
        for (int i = 0; i < length; i++) {
            System.out.print(primeNumbersArray[i] + " ");
        }
        System.out.println();
    }
}
